from django.http import HttpRequest, HttpResponse
from django.http import JsonResponse

from DjangoDemo.scripts.GetSiteMessage import Get_Site_Message
from DjangoDemo.scripts.GetToken import Get_Token

from django.http import HttpRequest, HttpResponse
from django.http import JsonResponse

from DjangoDemo.scripts.C2_1 import c2_1
from DjangoDemo.scripts.C2_2 import c2_2
from DjangoDemo.scripts.C2_3 import c2_3
from DjangoDemo.scripts.C2_4 import c2_4
from DjangoDemo.scripts.C3_1 import c3_1
from DjangoDemo.scripts.C3_2 import c3_2
from DjangoDemo.scripts.C3_3 import c3_3
from DjangoDemo.scripts.C3_4 import c3_4
from DjangoDemo.scripts.C3_5 import c3_5
from DjangoDemo.scripts.C3_7 import c3_7
from DjangoDemo.scripts.EquipmentsLocation import EquipmentsLocation
from DjangoDemo.scripts.Token import Token
from DjangoDemo.scripts.UserLocation import UserLocation

def hello(request):
    return HttpResponse("Hello world2 ! ")
def page_text(request):
    html = "json{年龄:12, id : 2929292}"
    return HttpResponse(html)


def page_textn(request, str_now, nxt, pre):
    ret = ""
    pre = float(pre)
    nxt = float(nxt)
    if str_now == "add":
        ret = pre + nxt
    elif str_now == "sub":
        ret = pre - nxt
    elif str_now == "mul":
        ret = pre * nxt
    else:
        ret = pre / nxt
    html = "<h1>The answer is %.0f<h1>" % ret
    return HttpResponse(html)


#     2.*
def C2_1(request):
    now = c2_1("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


def C2_2(request):
    now = c2_2("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


def C2_3(request):
    now = c2_3("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


def C2_4(request):
    now = c2_4("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


#   3.*
def C3_1(request):
    now = c3_1("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


def C3_2(request):
    now = c3_2("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


def C3_3(request):
    now = c3_3("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


def C3_4(request):
    now = c3_4("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


def C3_5(request):
    now = c3_5("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


def C3_7(request):
    now = c3_7("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


def FEquipmentsLocation(request):
    now = EquipmentsLocation("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


def FToken(request):
    now = Token()
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)


def FUserLocation(request):
    now = UserLocation("Shenzhen")
    ret = {
        'token': now.r.json(),
    }
    return JsonResponse(ret)
